#pragma once

// Qt's
#include <QObject>
#include <QMouseEvent>

#include "gant_global_define.h"
#include "FramelessWidget/frameless_widget.h"

class QLabel;
class QVBoxLayout;
class GAntFramelessWidgetPrivate : public QObject
{
    Q_OBJECT
    GANT_DECL_PUBLIC(GAntFramelessWidget)

public:
    enum MousePos
    {
        No = 0,
        Left = 0x01,
        Top = 0x02,
        Right = 0x04,
        Bottom = 0x08,
        TopLeft = Top | Left,
        TopRight = Top | Right,
        BottomLeft = Bottom | Left,
        BottomRight = Bottom | Right
    };

    Q_DECLARE_FLAGS(MousePosFlag, MousePos)
    Q_FLAG(MousePosFlag)

public:
    explicit GAntFramelessWidgetPrivate(GAntFramelessWidget* qptr);

    void updateRects(const QRect& rect);
    void updateMouseArrow();
    void resizeWidget(const QPoint& pos);
    void updateMouseStatus(const QPoint& pos);
    void moveWidget(const QPoint& pos);

    void handleMouseDblClick(QMouseEvent* event);
    void handleMouseMove(QMouseEvent* event);

    void setWidthHelper(int w);
    void setHeightHelper(int h);

public:
    void init();

public:
    QWidget* m_pTitleBar = nullptr;
    QVBoxLayout* m_pVLayout = nullptr;
    QLabel* m_pTitleLabel = nullptr;

    QRect m_rectTitle;
    QRect m_rectLeftBorder;
    QRect m_rectTopBorder;
    QRect m_rectRightBorder;
    QRect m_rectBottomBorder;

    MousePosFlag m_ePos;
    QPoint m_dragPos;
    bool m_bIsDrag;
    bool m_bIsPressTitle;

    bool m_bIsMoveable;
    bool m_bIsFixedWidth;
    bool m_bIsFixedHeight;
};
